package com.showcai.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.showcai.dao.VersionsMapper;
import com.showcai.module.FeedBack;
import com.showcai.module.Versions;
import com.showcai.service.VersionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class VersionsServiceImpl implements VersionsService {
    @Autowired
    VersionsMapper versionsMapper;
    @Override
    public void addVersions(Versions versions) {
        if(versions.getTid()==null){
            versions.setCreateTime(new Date());
            versionsMapper.addVersions(versions);
            return;
        }
        versionsMapper.updateVersionsById(versions);
    }

    @Override
    public Versions getLastVersions() {
        return versionsMapper.getLastVersions();
    }

    @Override
    public PageInfo getVersionsList(Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Versions>list =  versionsMapper.getVersionsList();
        PageInfo<Versions> pageinfo = new PageInfo<>(list);
        return pageinfo;
    }

    @Override
    public Versions selectVersionsById(Long tid) {
        return versionsMapper.selectVersionsById(tid);
    }

    @Override
    public void updateVersionsById(Versions versions) {

    }
}
